package com.omega.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.omega.dao.MeasuringUnitDao;
import com.omega.entity.MeasuringUnit;
import com.omega.service.MeasuringUnitService;

@Service
public class MeasuringUnitServiceImpl implements MeasuringUnitService {

	@Autowired
	MeasuringUnitDao measuringUnitDao;
	
	@Override
	@Transactional
	public void addMeasuringUnit(MeasuringUnit measuringUnit) {
		measuringUnitDao.addMeasuringUnit(measuringUnit);
	}

	@Override
	@Transactional
	public List<MeasuringUnit> loadAllMeasuringUnits() {
		return measuringUnitDao.loadAllMeasuringUnits();
	}

	@Override
	@Transactional
	public MeasuringUnit loadById(Integer measuringUnitId) {
		return measuringUnitDao.loadById(measuringUnitId);
	}

	@Override
	@Transactional
	public void updateMeasuringUnit(MeasuringUnit measuringUnit) {
		MeasuringUnit unit = measuringUnitDao.loadById(measuringUnit.getMeasuringUnitId());
		unit.setMeasuringUnitValue(measuringUnit.getMeasuringUnitValue());
		measuringUnitDao.updateSupplier(unit);
		
	}

}
